package apdate

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.wd.common.bean.ZhuanRimBean
import com.wd.rim.R

class ZhuanApdate(var context: Context, var list: List<ZhuanRimBean.Result>):
    RecyclerView.Adapter<ZhuanApdate.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_zhuan, parent, false)
        return ViewHolder(view)
    }

    override fun getItemCount(): Int {
        return list.size
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.name.text = list[position].brandList.get(0).name
        Glide.with(context).load(list[position].brandList.get(0).imageUrl)
            .into(holder.img)

    }

    class ViewHolder(itemView: View):RecyclerView.ViewHolder(itemView){
        val img:ImageView
        val name:TextView
        init {
             img = itemView.findViewById<ImageView>(R.id.image_id)
             name = itemView.findViewById<TextView>(R.id.name)
        }
    }

}